package util

import (
	"encoding/json"
	"fmt"
	"os"
)

func WriteJson(path string, obj interface{}) error {
	file, err := os.Create(path)
	if err != nil {
		return err
	}
	
	defer file.Close()
	encoder := json.NewEncoder(file)
	err = encoder.Encode(obj)
	if err != nil {
		fmt.Println(err.Error())
		return err
	}

	return nil
}